/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JFreeChartExtensions.chartextensions.crosshair;

import JFreeChartExtensions.chartextensions.AbstractChartPanelExtension;
import JFreeChartExtensions.chartextensions.crosshair.CrossHairManager;
import JFreeChartExtensions.ExtendableChartPanel;
import JFreeChartExtensions.JChartMenu.ChartMenuListeners.CrosshairPropertiesListener;
import JFreeChartExtensions.JChartMenu.JChartMenu;
import JFreeChartExtensions.containers.InternalFrameWithChart.InternalFrameWithChart;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author Nobody
 */
public class CrossHairExtension extends AbstractChartPanelExtension {

    private JChartMenu setScaleMenuItem;

    public CrossHairExtension(ExtendableChartPanel panel) {
        super(panel);
        name = "CrossHairExtension";
    }

    @Override
    public void applyExtension(ChartPanel chartPanel) {
        this.chartPanel = (ExtendableChartPanel) chartPanel;

        setScaleMenuItem = new JChartMenu("Crosshair properties...");
        setScaleMenuItem.addListener(new CrosshairPropertiesListener((ExtendableChartPanel) chartPanel));
        chartPanel.getPopupMenu().add(setScaleMenuItem);


        chartExtensionManager = new CrossHairManager((ExtendableChartPanel) chartPanel, false, true, true);
        chartExtensionManager.register(chartPanel);

    }

    @Override
    public void removeExtension() {
        chartPanel.getPopupMenu().remove(chartPanel);
        chartExtensionManager.unregister();
    }
}
